﻿using System;
using System.Collections.Generic;
using System.Web;

namespace MyWebPagesStarterKit.Rewriter
{
    /// <summary>
    /// The base class for module rewriting of sections. This class is abstract, and therefore must be derived from.
    /// </summary>
    /// <remarks>Provides the essential base functionality for a rewriter using the HttpModule approach.</remarks>
    public abstract class ISectionRewriter : IHttpModule
    {
        public virtual void Init(HttpApplication app)
        {
            app.AuthorizeRequest += new EventHandler(this.ISectionRewriter_AuthorizeRequest);
        }

        protected virtual void ISectionRewriter_AuthorizeRequest(object sender, EventArgs e)
        {
            HttpApplication app = (HttpApplication)sender;
            Rewrite(app.Request.Path, app);
        }

        public virtual void Dispose() { }

        protected abstract void Rewrite(string requestedPath, HttpApplication app);
    }
}

